//追加一个笔记本li
function createBookLi(bookName,bookId){
    var s_li = '<li class="online">'
    s_li += '<a>'
    s_li += '<i class="fa fa-book" title="online" rel="tooltip-bottom">'
    s_li += '</i>' + bookName
    s_li += '</a>'
    s_li += '</li>';
    //将bookId绑定
    var $li = $(s_li);
    $li.data("bookId",bookId);
    //将bookId追加到ul
    $("#book_list").append($li);
}

function loadUserBooks(){
    $.ajax({
        url: base_url + "/notebook/loadbooks.do",
        type: "post",
        data: {"userId":userId},
        dataType: "json",
        success: function(result){
            var books = result.data;
            //console.log(result)
            for(var i=0;i<books.length;i++){
                bookName = books[i].cn_notebook_name;
                bookId = books[i].cn_notebook_id;
                //拼接一个li
                createBookLi(bookName,bookId)
            }
        },
        error: function(){
            alert("加载笔记列表失败");
        }
    });
}